from appium.webdriver.common.appiumby import AppiumBy

from page.base_page import BasePage


class SearchPage(BasePage):
    _input_locator = (AppiumBy.ID, "search_input_text")
    _name_locator = (AppiumBy.ID, "name")

    def search(self, keyword):
        self.find_element(self._input_locator).send_keys(keyword)
        self.find_element(self._name_locator).click()

        return self

    _price_locator = (AppiumBy.ID, "current_price")

    def get_current_price(self):
        return float(self.find_element(self._price_locator).text)
